package Class_Object.继承;


class Base {
    public int a = 3;
    public int c;

    public Base(int a, int c) {
        this.a = a;
        this.c = c;
    }

    public void method(){
        System.out.println("Base:method");
    }
}
class Derived extends Base {

    public int a = 10;
    public int b;

    public Derived(int a, int c) {
        super(a, c);
    }

    public void method(){
        System.out.println("Derived::method");
    }
    public void test() {
        super.method();//调用的是父类的方法
        this.method();//调用的是子类的方法
        System.out.println(this.a);
        System.out.println(a);
        System.out.println(super.a);
    }
}
public class Test {
    public static void main(String[] args) {
        Derived derived = new Derived(1,2);
        //super不能在静态方法使用
        //当子类和父类有同名的成员变量的时候,先看子类自己有没有,再看父类有没有
        derived.test();
    }


}
